<extend name="Layout/application"/>

<block name="css">
   <style>
      .am-form-file {
         position: relative;
         overflow: hidden
      }

      .am-form-file input[type=file] {
         position: absolute;
         left: 0;
         top: 0;
         z-index: 1;
         width: 100%;
         opacity: 0;
         cursor: pointer;
         font-size: 50rem
      }
   </style>
</block>
<block name="content">
   <section class="content-header">
      <h1>
         编辑分类
         <small>Category Edit</small>
      </h1>
      <ol class="breadcrumb">
         <li><a href="#"><i class="fa fa-dashboard"></i> Category</a></li>
         <li class="active">Edit</li>
      </ol>
   </section>

   <section class="content" style="width: 1000px;">
      <div class="box box-success">

         <div class="box-body">
            <form role="form" method="post" action="{{:url('categories/update',['id'=>$cate.id])}}">
               <div class="box-body">
                  <div class="form-group">
                     <label>上级分类</label>
                     <select class="form-control" name="parent_id">
                        <option value="0">顶级分类</option>
                        <volist name="categories" id="category">
                           <option value="{{$category.id}}"
                           <eq name="category.id" value="$cate.parent_id">selected</eq>
                           >{{$category.name}}</option>
                           <volist name="category.children" id="children">
                              <option value="{{$children.id}}"
                              <eq name="children.id" value="$cate.parent_id">selected</eq>
                              >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+++{{$children.name}}
                              </option>
                           </volist>

                        </volist>
                     </select>
                  </div>
                  <div class="form-group">
                     <label>分类名称</label>
                     <input type="text" name="name" class="form-control" value="{{$cate.name}}">
                  </div>

                  <div class="form-group">
                     <label>缩略图</label>
                     <div class="form-group am-form-file">
                        <button class="btn btn-warning"><i class="fa fa-upload" id="loading"></i>上传的缩略图</button>
                        <input type="file" id="image_upload">
                        <input type="hidden" name="photo_id" value="{{$cate.photo_id}}">
                     </div>
                     <div>
                        <img src="$cate.photo.image or http://oze5mdef4.bkt.clouddn.com/cec3f09beaf1f2051ad51277fa2da422.png"
                             id="img_show" style="max-height: 150px;">
                     </div>
                  </div>
                  <div class="form-group">
                     <label>排序</label>
                     <input type="text" name="sort_order" class="form-control" value="{{$cate.sort_order}}">
                  </div>


                  <div class="form-group">
                     <label>分类描述</label>
                     <textarea name="description" class="form-control">{{$cate.description}}</textarea>
                  </div>


                  <div class="box-footer">
                     <button type="submit" class="btn btn-primary">提交</button>
                     <button type="reset" class="btn btn-default">重置</button>
                  </div>
               </div>
            </form>
         </div>
      </div>

   </section>
</block>

<block name="js">
   <!--上传图片-->
   <script src="/vendor/qiniu/jquery.html5-fileupload.js"></script>
   <script src="/vendor/qiniu/upload.js"></script>

</block>



